<?php 
/**
 * 管理员model类
 * @Author    紫梦
 * @DateTime  2017-11-18
 * @copyright 响响租车
 * @version   1.0
 */
namespace app\common\model;
use think\Model;

class Admin extends Model
{    

    // 定义全局的查询范围
    protected static function base($query)
    {
        $agency = session('admin.agency_id');
        if($agency == 1){
            // $query->where('delete_time',null);

        }else{
            $query->where(['agency_id'=>$agency]);

        }
                    
    } 

    public function rolesNode()
    {
        return $this->hasMany('RolesNode','role_id','role_id');
    }

    public function roles()
    {
        return $this->hasOne('Roles','id','role_id');
    }

    public function agency()
    {
        return $this->hasOne('Agency','id','agency_id')->field('id,name');
    }
	
}